//  Figure A.5 Weak Ties	  

clear all
clear matrix
set more off

* Data ready for analysis:

use "~/Dropbox/Replication_MVC/Datasets/datasets_analysis/panel_excombatientes.dta", clear 

* Def mean value of economic shock for the group 
sort Exestructura
by Exestructura: egen mean_gold_production_weakties=mean(oro_sin_titulo)
gen mean_gold_shock_weakties=mean_gold_production_weakties*log_gold_price

sum mean_gold_shock_weakties
generate mean_gold_shock_weakties_r = (mean_gold_shock_weakties-r(mean))/r(sd)
 
eststo clear
set more off
 
*All captures
reghdfe diffcaptures gold_shock_r mean_gold_shock_weakties_r, absorb(Exestructura year origmun) vce(cluster Exestructura)
nlcom _b[mean_gold_shock_weakties_r]/(_b[gold_shock_r] + _b[mean_gold_shock_weakties_r]), post
eststo 
estimates store All1

reghdfe diffcaptures gold_shock_r mean_gold_shock_weakties_r c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t, absorb(Exestructura year origmun) vce(cluster Exestructura)
nlcom _b[mean_gold_shock_weakties_r]/(_b[gold_shock_r] + _b[mean_gold_shock_weakties_r]), post
eststo 
estimates store All2

reghdfe diffcaptures gold_shock_r mean_gold_shock_weakties_r age female black indigenous c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t, absorb(Exestructura year origmun) vce(cluster Exestructura)
nlcom _b[mean_gold_shock_weakties_r]/(_b[gold_shock_r] + _b[mean_gold_shock_weakties_r]), post
eststo 
estimates store All3

* Red-handed Captures
reghdfe diffcaptures_f gold_shock_r mean_gold_shock_weakties_r, absorb(Exestructura year origmun) vce(cluster Exestructura)
nlcom _b[mean_gold_shock_weakties_r]/(_b[gold_shock_r] + _b[mean_gold_shock_weakties_r]), post
eststo 
estimates store RH1

reghdfe diffcaptures_f gold_shock_r mean_gold_shock_weakties_r c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t, absorb(Exestructura year origmun) vce(cluster Exestructura)
nlcom _b[mean_gold_shock_weakties_r]/(_b[gold_shock_r] + _b[mean_gold_shock_weakties_r]), post
eststo 
estimates store RH2

reghdfe diffcaptures_f gold_shock_r mean_gold_shock_weakties_r age female black indigenous c.pobreza##c.time_t c.pobl_tot##c.time_t c.disbogota##c.time_t c.paved_roads##c.time_t, absorb(Exestructura year origmun) vce(cluster Exestructura)
nlcom _b[mean_gold_shock_weakties_r]/(_b[gold_shock_r] + _b[mean_gold_shock_weakties_r]), post
eststo 
estimates store RH3

* Plot    	 
coefplot (All1) (All2) (All3) (RH1) (RH2) (RH3), vertical legend(rows(1)) ///
         graphregion(color(white)) bgcolor(white)  ytitle("Peer Effect") ///
         yline(0, lpattern(dash) lcolor(gray)) pstyle(p5)	 
		 
